package com.wutu.nbyjk8.exception;

import feign.Response;
import feign.RetryableException;
import feign.codec.ErrorDecoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Author: Addons
 * @Date: 2022-03-30 17:45
 * @Desc:
 */
//@Configuration
public class LampFeignException extends ErrorDecoder.Default {

    private final Logger log = LoggerFactory.getLogger(LampFeignException.class);

    @Override
    public Exception decode(String methodKey, Response response) {
        Exception exception = super.decode(methodKey, response);

        // 如果是RetryableException，则返回继续重试
        if (exception instanceof RetryableException) {
            return exception;
        } else {
            // 可以自定义一些逻辑，比如抛出一个其他的(统一个异常)
            exception = new RuntimeException(exception.getMessage());
            //SmartLightUtil.cleanTokenAndSession();
        }
        return exception;
    }


}
